﻿using System;

namespace HZY.Toolkit
{
    /// <summary>
    /// MVC 异常拦截 该对象 返回客户端
    /// </summary>
    [Serializable]
    public class MessageBox : Exception
    {
        /// <summary>
        /// 异常模型
        /// </summary>
        public ApiResult Model { set; get; }

        public MessageBox(string result) : base(result)
            => this.Model = new ApiResult(ApiResultCodeEnum.错误, string.IsNullOrWhiteSpace(this.Message) ? "操作失败!" : this.Message);

        public MessageBox(object result, ApiResultCodeEnum apiResultCodeEnum) : base($"自定义异常 请忽略!")
            => this.Model = new ApiResult(apiResultCodeEnum, result);


    }
}
